<%@page language="java" pageEncoding="gb2312"%>
<%@page import="java.util.*"%>
<%@page import="com.mysql.jdbc.Driver"%>
<%@page import="java.sql.*"%>
<%@page import="com.mysql.jdbc.ResultSetMetaData"%>

<%

if(session.getAttribute("username")==null)
{
    response.sendRedirect("error.jsp");
}

String path = request.getContextPath();
String basePath = request.getScheme() + "://" + 
  request.getServerName() + ":" + request.getServerPort() + 
  path + "/";

String driverName = "com.mysql.jdbc.Driver";
String DBUser = "*";
String DBPasswd = "*";
String DBName = "*";

String connUrl = "jdbc:mysql://localhost/" + DBName + "?useUnicode=true&characterEncoding=utf-8&user=" + 
  DBUser + "&password=" + DBPasswd;

Class.forName(driverName).newInstance();
Connection conn = DriverManager.getConnection(connUrl);
Statement stmt = conn.createStatement();
stmt.executeQuery("SET NAMES UTF8");

request.setCharacterEncoding("GB2312");

String fiberid = request.getParameter("fiberid");
String useflag = request.getParameter("useflag");
String usedesc = request.getParameter("usedesc");

String length = request.getParameter("length");
String mark = request.getParameter("mark");

String sql = "update fiberinfo set useflag = " + useflag + ", usedesc = '" + usedesc + "', length = " + length + ", mark = '" + mark + "' where fiberid = " + fiberid;

stmt.executeUpdate(sql);

stmt.executeQuery("commit");  //save
conn.close();
stmt.close();

response.sendRedirect("fibercableinfo.jsp");
%>
